home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / ncurses-5.3.lha / ncurses-5.3 / progs / MKtermsort.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2002-10-24  |  6KB  |  165 lines

  1. #!/bin/sh
  2. # $Id: MKtermsort.sh,v 1.8 2002/06/29 20:02:48 tom Exp $
  3. #
  4. # MKtermsort.sh -- generate indirection vectors for the various sort methods
  5. #
  6. ##############################################################################
  7. # Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.                #
  8. #                                                                            #
  9. # Permission is hereby granted, free of charge, to any person obtaining a    #
  10. # copy of this software and associated documentation files (the "Software"), #
  11. # to deal in the Software without restriction, including without limitation  #
  12. # the rights to use, copy, modify, merge, publish, distribute, distribute    #
  13. # with modifications, sublicense, and/or sell copies of the Software, and to #
  14. # permit persons to whom the Software is furnished to do so, subject to the  #
  15. # following conditions:                                                      #
  16. #                                                                            #
  17. # The above copyright notice and this permission notice shall be included in #
  18. # all copies or substantial portions of the Software.                        #
  19. #                                                                            #
  20. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
  21. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
  22. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
  23. # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
  24. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
  25. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
  26. # DEALINGS IN THE SOFTWARE.                                                  #
  27. #                                                                            #
  28. # Except as contained in this notice, the name(s) of the above copyright     #
  29. # holders shall not be used in advertising or otherwise to promote the sale, #
  30. # use or other dealings in this Software without prior written               #
  31. # authorization.                                                             #
  32. ##############################################################################
  33. #
  34. # The output of this script is C source for nine arrays that list three sort
  35. # orders for each of the three different classes of terminfo capabilities.
  36. #
  37. # keep the order independent of locale:
  38. if test "${LANGUAGE+set}"    = set; then LANGUAGE=C;    export LANGUAGE;    fi
  39. if test "${LANG+set}"        = set; then LANG=C;        export LANG;        fi
  40. if test "${LC_ALL+set}"      = set; then LC_ALL=C;      export LC_ALL;      fi
  41. if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
  42. if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
  43. if test "${LC_COLLATE+set}"  = set; then LC_COLLATE=C;  export LC_COLLATE;  fi
  44. #
  45. AWK=${1-awk}
  46. DATA=${2-../include/Caps}
  47.  
  48. data=data$$
  49. trap 'rm -f $data' 1 2 5 15
  50. sed -e 's/[    ]\+/    /g' < $DATA >$data
  51. DATA=$data
  52.  
  53. echo "/*";
  54. echo " * termsort.c --- sort order arrays for use by infocmp.";
  55. echo " *";
  56. echo " * Note: this file is generated using MKtermsort.sh, do not edit by hand.";
  57. echo " */";
  58.  
  59. echo "static const int bool_terminfo_sort[] = {";
  60. $AWK <$DATA '
  61. BEGIN           {i = 0;}
  62. /^#/            {next;}
  63. $3 == "bool"    {printf("%s\t%d\n", $2, i++);}
  64. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  65. echo "};";
  66. echo "";
  67.  
  68. echo "static const int num_terminfo_sort[] = {";
  69. $AWK <$DATA '
  70. BEGIN           {i = 0;}
  71. /^#/            {next;}
  72. $3 == "num"     {printf("%s\t%d\n", $2, i++);}
  73. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  74. echo "};";
  75. echo "";
  76.  
  77. echo "static const int str_terminfo_sort[] = {";
  78. $AWK <$DATA '
  79. BEGIN           {i = 0;}
  80. /^#/            {next;}
  81. $3 == "str"     {printf("%s\t%d\n", $2, i++);}
  82. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  83. echo "};";
  84. echo "";
  85.  
  86. echo "static const int bool_variable_sort[] = {";
  87. $AWK <$DATA '
  88. BEGIN           {i = 0;}
  89. /^#/            {next;}
  90. $3 == "bool"    {printf("%s\t%d\n", $1, i++);}
  91. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  92. echo "};";
  93. echo "";
  94.  
  95. echo "static const int num_variable_sort[] = {";
  96. $AWK <$DATA '
  97. BEGIN           {i = 0;}
  98. /^#/            {next;}
  99. $3 == "num"     {printf("%s\t%d\n", $1, i++);}
  100. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  101. echo "};";
  102. echo "";
  103.  
  104. echo "static const int str_variable_sort[] = {";
  105. $AWK <$DATA '
  106. BEGIN           {i = 0;}
  107. /^#/            {next;}
  108. $3 == "str"     {printf("%s\t%d\n", $1, i++);}
  109. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  110. echo "};";
  111. echo "";
  112.  
  113. echo "static const int bool_termcap_sort[] = {";
  114. $AWK <$DATA '
  115. BEGIN           {i = 0;}
  116. /^#/            {next;}
  117. $3 == "bool"    {printf("%s\t%d\n", $4, i++);}
  118. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  119. echo "};";
  120. echo "";
  121.  
  122. echo "static const int num_termcap_sort[] = {";
  123. $AWK <$DATA '
  124. BEGIN           {i = 0;}
  125. /^#/            {next;}
  126. $3 == "num"     {printf("%s\t%d\n", $4, i++);}
  127. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  128. echo "};";
  129. echo "";
  130.  
  131. echo "static const int str_termcap_sort[] = {";
  132. $AWK <$DATA '
  133. BEGIN           {i = 0;}
  134. /^#/            {next;}
  135. $3 == "str"     {printf("%s\t%d\n", $4, i++);}
  136. ' | sort | $AWK '{print "\t", $2, ",\t/* ", $1, " */";}';
  137. echo "};";
  138. echo "";
  139.  
  140. echo "static const bool bool_from_termcap[] = {";
  141. $AWK <$DATA '
  142. $3 == "bool" && substr($7, 1, 1) == "-"       {print "\tFALSE,\t/* ", $2, " */";}
  143. $3 == "bool" && substr($7, 1, 1) == "Y"       {print "\tTRUE,\t/* ", $2, " */";}
  144. '
  145. echo "};";
  146. echo "";
  147.  
  148. echo "static const bool num_from_termcap[] = {";
  149. $AWK <$DATA '
  150. $3 == "num" && substr($7, 1, 1) == "-"        {print "\tFALSE,\t/* ", $2, " */";}
  151. $3 == "num" && substr($7, 1, 1) == "Y"        {print "\tTRUE,\t/* ", $2, " */";}
  152. '
  153. echo "};";
  154. echo "";
  155.  
  156. echo "static const bool str_from_termcap[] = {";
  157. $AWK <$DATA '
  158. $3 == "str" && substr($7, 1, 1) == "-"        {print "\tFALSE,\t/* ", $2, " */";}
  159. $3 == "str" && substr($7, 1, 1) == "Y"        {print "\tTRUE,\t/* ", $2, " */";}
  160. '
  161. echo "};";
  162. echo "";
  163.  
  164. rm -f $data
  165.